package services;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import domain.Customer;

import repositories.CustomerRepository;
import security.LoginService;
import security.UserAccount;

@Service
@Transactional
public class CustomerService {
	
	// Managed repository -----------------------
	@Autowired
	private CustomerRepository customerRepository;	
	
	// Supporting services -----------------------
		
	// Simpled CRUD methods ----------------------
	
	//Other business methods  -----------------------------
	public Customer findByPrincipal() {
		return findByUserAccount(LoginService.getPrincipal());
	}
	public Customer findByUserAccount(UserAccount userAccount){
		return customerRepository.findByUserAccount(userAccount);
	}
	
}
